package com.gc.business.service.impl;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gc.common.utils.StringUtils;
import org.springframework.stereotype.Service;
import com.gc.business.mapper.MemoNoteMapper;
import com.gc.business.domain.MemoNote;
import com.gc.business.service.IMemoNoteService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;

/**
 * 备忘录 服务层实现
 * 
 * @author liujinteng
 * @date 2020-12-02
 */
@Slf4j
@Service
public class MemoNoteServiceImpl extends ServiceImpl<MemoNoteMapper, MemoNote> implements IMemoNoteService {

    @Override
    public List<MemoNote> list(MemoNote memoNote){
        LambdaQueryWrapper<MemoNote> wrapper = new LambdaQueryWrapper<>();
        if(memoNote != null){
            if(StringUtils.isNotEmpty(memoNote.getMemoId())){
                wrapper.eq(MemoNote::getMemoId, memoNote.getMemoId());
            }
            if(StringUtils.isNotEmpty(memoNote.getUserId())){
                wrapper.eq(MemoNote::getUserId, memoNote.getUserId());
            }
            if(StringUtils.isNotEmpty(memoNote.getMemoTitle())){
                wrapper.like(MemoNote::getMemoTitle, memoNote.getMemoTitle());
            }
            if(StringUtils.isNotEmpty(memoNote.getMemoContent())){
                wrapper.like(MemoNote::getMemoContent, memoNote.getMemoContent());
            }
            if(StringUtils.isNotEmpty(memoNote.getCreateBy())){
                wrapper.like(MemoNote::getCreateBy, memoNote.getCreateBy());
            }
            if(StringUtils.isNotEmpty(memoNote.getCreateTime())){
                wrapper.eq(MemoNote::getCreateTime, memoNote.getCreateTime());
            }
            if(StringUtils.isNotEmpty(memoNote.getUpdateBy())){
                wrapper.like(MemoNote::getUpdateBy, memoNote.getUpdateBy());
            }
            if(StringUtils.isNotEmpty(memoNote.getUpdateTime())){
                wrapper.eq(MemoNote::getUpdateTime, memoNote.getUpdateTime());
            }
            if(StringUtils.isNotEmpty(memoNote.getRemark())){
                wrapper.like(MemoNote::getRemark, memoNote.getRemark());
            }
        }
        return baseMapper.selectList(wrapper);
    }
}
